cmake_minimum_required(VERSION 3.5)

project(myfs)

set(CMAKE_CXX_COMPILER "D:/mingw64/bin/c++.exe")

# 设置指定的C++编译器版本是必须的，如果不设置，或者为OFF，则指定版本不可用时，会使用上一版本。
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 17)

# 默认OFF
option(TEST "option for test" ON) 

# set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE Release)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

link_directories(${PROJECT_SOURCE_DIR}/lib)
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(${PROJECT_SOURCE_DIR}/src)

if(TEST)
    add_subdirectory(${PROJECT_SOURCE_DIR}/3rdParty/googletest-release-1.11.0)
    include_directories(${PROJECT_SOURCE_DIR}/3rdParty/googletest-release-1.11.0/googletest/include)
    enable_testing()
    set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/test_bin)

    add_executable(test_all ${PROJECT_SOURCE_DIR}/test/main.cpp)
    target_link_libraries(test_all gtest gtest_main myfs)

    add_executable(test_allocator ${PROJECT_SOURCE_DIR}/test/test_allocator.cpp)
    target_link_libraries(test_allocator gtest gtest_main myfs)

    add_executable(test_log ${PROJECT_SOURCE_DIR}/test/test_log.cpp)
    target_link_libraries(test_log gtest gtest_main myfs)

    add_executable(test_assert ${PROJECT_SOURCE_DIR}/test/test_assert.cpp)
    target_link_libraries(test_assert gtest gtest_main myfs)
endif()